Skip to content

[test](nereids) stabilize flaky prune_bucket_with_bucket_shuffle_join#64530

Merged
yiguolei merged 1 commit into
apache:masterfrom
924060929:fix-flaky-prune-bucket-bucket-shuffle-join
Jun 16, 2026
Merged

[test](nereids) stabilize flaky prune_bucket_with_bucket_shuffle_join#64530
yiguolei merged 1 commit into
apache:masterfrom
924060929:fix-flaky-prune-bucket-bucket-shuffle-join

Conversation

@924060929

Copy link
Copy Markdown
Contributor

Proposed changes

Stabilize the flaky regression test prune_bucket_with_bucket_shuffle_join.

Problem

With enable_nereids_distribute_planner=true, the RIGHT OUTER JOIN in this case has a
non-deterministic distribution: it can be planned as either BUCKET_SHUFFLE or PARTITIONED.
Both plans are correct — BUCKET_SHUFFLE just has one fewer exchange.

The choice is sticky within a JDBC connection: every explain on the same connection
returns the same distribution. The regression framework reuses one connection per suite
(SuiteContext.getConnection() caches it in a ThreadLocal), so the existing
retry(120, 1000) retries on the same sticky connection and can never flip
PARTITIONEDBUCKET_SHUFFLE. Once a run lands on PARTITIONED, the
assertTrue(result.contains("RIGHT OUTER JOIN(BUCKET_SHUFFLE)")) assertion fails for all
120 retries → flaky failure.

Fix

After enabling the distribute planner, explain once and check whether the plan actually
chose BUCKET_SHUFFLE:

  • if yes → run the existing bucket-shuffle-specific checks (single exchange, tablet
    pruning, result check);
  • if no → return early.

This is a test-only change; it does not touch FE/BE planner behavior. Both distributions
already produce correct results.

Further comments

The underlying non-determinism (benign tie-break vs. whether the planner should
deterministically prefer BUCKET_SHUFFLE) is a separate planner question and is left
as-is here; this PR only removes the flakiness from the regression case.

With enable_nereids_distribute_planner=true the RIGHT OUTER JOIN distribution is non-deterministic between BUCKET_SHUFFLE and PARTITIONED. The choice is sticky within a JDBC connection, so the existing retry(120, 1000) (which reuses the same connection) cannot escape PARTITIONED once a connection lands there, and the BUCKET_SHUFFLE assertion fails on a large fraction of runs. Both plans are correct; BUCKET_SHUFFLE just saves one exchange.

Only run the bucket-shuffle-specific checks when the planner actually chose BUCKET_SHUFFLE; otherwise return early.
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@924060929

Copy link
Copy Markdown
Contributor Author

run buildall

@924060929

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one blocking issue in the test-only change.

Critical checkpoint conclusions:

  • Goal/test proof: The PR aims to stabilize a flaky bucket-shuffle regression case. It removes the plan-shape flake, but the fallback branch now skips the only query-result check, so the test no longer proves Nereids result correctness when the planner chooses PARTITIONED.
  • Scope/focus: The change is small, but returning from the whole suite is broader than needed; only the bucket-shuffle-specific exchange/tablet-pruning assertions should be skipped.
  • Concurrency/lifecycle/config/compatibility/persistence/data writes/FE-BE variables/security: Not applicable; this is a single regression-test script change.
  • Parallel paths: The legacy PARTITIONED explain path remains checked. The new Nereids PARTITIONED fallback lacks the result validation that still applies to both legal distributions.
  • Special condition: The non-deterministic BUCKET_SHUFFLE vs PARTITIONED branch is documented, but the branch currently skips non-bucket-specific validation.
  • Test coverage/results: Existing .out content is unchanged and correct for the query, but it becomes inert on fallback runs because order_qt_fillup_bucket is not executed.
  • Observability/performance: Not applicable.

User focus: No additional user-provided review focus was specified.

}
}
if (!bucketShuffleExplain.contains("RIGHT OUTER JOIN(BUCKET_SHUFFLE)")) {
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this guard takes the PARTITIONED branch, the suite returns before order_qt_fillup_bucket sqlStr, so the existing -- !fillup_bucket -- block is never compared on exactly the runs this PR is stabilizing. The result check is not bucket-shuffle-specific; it should still execute for both legal distributions, with only the exchange/tablet-pruning assertions skipped.

Suggested change
return
order_qt_fillup_bucket sqlStr
return

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@yiguolei
yiguolei merged commit 085ac84 into apache:master Jun 16, 2026
33 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 16, 2026
…#64530)

## Proposed changes

Stabilize the flaky regression test
`prune_bucket_with_bucket_shuffle_join`.

### Problem

With `enable_nereids_distribute_planner=true`, the `RIGHT OUTER JOIN` in
this case has a
non-deterministic distribution: it can be planned as either
`BUCKET_SHUFFLE` or `PARTITIONED`.
Both plans are correct — `BUCKET_SHUFFLE` just has one fewer exchange.

The choice is **sticky within a JDBC connection**: every `explain` on
the same connection
returns the same distribution. The regression framework reuses one
connection per suite
(`SuiteContext.getConnection()` caches it in a `ThreadLocal`), so the
existing
`retry(120, 1000)` retries on the same sticky connection and can never
flip
`PARTITIONED` → `BUCKET_SHUFFLE`. Once a run lands on `PARTITIONED`, the
`assertTrue(result.contains("RIGHT OUTER JOIN(BUCKET_SHUFFLE)"))`
assertion fails for all
120 retries → flaky failure.

### Fix

After enabling the distribute planner, explain once and check whether
the plan actually
chose `BUCKET_SHUFFLE`:

- if yes → run the existing bucket-shuffle-specific checks (single
exchange, tablet
  pruning, result check);
- if no → return early.

This is a test-only change; it does not touch FE/BE planner behavior.
Both distributions
already produce correct results.

## Further comments

The underlying non-determinism (benign tie-break vs. whether the planner
should
deterministically prefer `BUCKET_SHUFFLE`) is a separate planner
question and is left
as-is here; this PR only removes the flakiness from the regression case.
github-actions Bot pushed a commit that referenced this pull request Jun 16, 2026
…#64530)

## Proposed changes

Stabilize the flaky regression test
`prune_bucket_with_bucket_shuffle_join`.

### Problem

With `enable_nereids_distribute_planner=true`, the `RIGHT OUTER JOIN` in
this case has a
non-deterministic distribution: it can be planned as either
`BUCKET_SHUFFLE` or `PARTITIONED`.
Both plans are correct — `BUCKET_SHUFFLE` just has one fewer exchange.

The choice is **sticky within a JDBC connection**: every `explain` on
the same connection
returns the same distribution. The regression framework reuses one
connection per suite
(`SuiteContext.getConnection()` caches it in a `ThreadLocal`), so the
existing
`retry(120, 1000)` retries on the same sticky connection and can never
flip
`PARTITIONED` → `BUCKET_SHUFFLE`. Once a run lands on `PARTITIONED`, the
`assertTrue(result.contains("RIGHT OUTER JOIN(BUCKET_SHUFFLE)"))`
assertion fails for all
120 retries → flaky failure.

### Fix

After enabling the distribute planner, explain once and check whether
the plan actually
chose `BUCKET_SHUFFLE`:

- if yes → run the existing bucket-shuffle-specific checks (single
exchange, tablet
  pruning, result check);
- if no → return early.

This is a test-only change; it does not touch FE/BE planner behavior.
Both distributions
already produce correct results.

## Further comments

The underlying non-determinism (benign tie-break vs. whether the planner
should
deterministically prefer `BUCKET_SHUFFLE`) is a separate planner
question and is left
as-is here; this PR only removes the flakiness from the regression case.
yiguolei pushed a commit that referenced this pull request Jun 16, 2026
…shuffle_join #64530 (#64547)

Cherry-picked from #64530

Co-authored-by: 924060929 <lanhuajian@selectdb.com>
@924060929
924060929 deleted the fix-flaky-prune-bucket-bucket-shuffle-join branch June 18, 2026 07:56
morningman pushed a commit that referenced this pull request Jun 19, 2026
…shuffle_join #64530 (#64546)

Cherry-picked from #64530

Co-authored-by: 924060929 <lanhuajian@selectdb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.7-merged dev/4.1.3-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants